using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PropBallsSpawner : MonoBehaviour
{
    private GameObject[] itemPrefabs;
    private BagModel ballbag;
    private int emptyBagCount;
    public FieldBallView[,] itemList;
    private Transform m_itemRoot;

    private void Awake() {
        m_itemRoot = transform;
    }

    private void Start() {
        ballbag = new BagModel();
        SpawnItemArrayList();
    }

    /// <summary>
    /// 生成多行多列道具球
    /// </summary>
    private void SpawnItemArrayList() {
        itemList = new FieldBallView[GlobalDef.ROW_COUNT, GlobalDef.COLUM_COUNT];
        for (int rowIndex = 0; rowIndex < GlobalDef.ROW_COUNT; ++rowIndex) {
            for (int columIndex = 0; columIndex < GlobalDef.COLUM_COUNT; ++columIndex) {
                var item = AddRandomPropBallItem(rowIndex, columIndex);
                itemList[rowIndex, columIndex] = item;
            }
        }
    }

    /// <summary>
    /// 随机一个道具球
    /// </summary>
    private FieldBallView AddRandomPropBallItem(int rowIndex, int columIndex) {
        //// 随机一个道具球类型
        //var entry = ballbag.ballCounter.GetNotEmptyEntryRandomly();
        //if (entry.isInvalid)
        //{
        //  return;
        //}
        //if (ball == null) {
        //    return null;//代表道具球全部用完没有可以生成的了
        //}
        //var item = new GameObject("item");
        //item.transform.SetParent(m_itemRoot, false);
        //item.AddComponent<BoxCollider2D>().size = Vector2.one * GlobalDef.GRID_SIZE;
        //var bhv = item.AddComponent<FieldBallView>();
        //return bhv;
        return null;
    }

    public void ReLoad()//再装填//旧的全部隐藏没写，对象池没有使用
    {
        SpawnItemArrayList();
    }
}
